<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../bootstrap/css/bootstrap.css">
    <script src="../jquery/jquery-3.4.1.min.js"></script>
</head>
<body>
<a href="/gotoxtcourse" >返回到课程</a>
<div class="row" style="margin-left: 78px;margin-top: 30px;" id="xt">

</div>
<script>
    $(document).ready(function () {
        var s_id;
        var html1="";
        $.ajax({
            url: "sixCourse/selectAll",
            type: "get",
            dataType: "json",
            // async:false,//同步方法，确保获取到id在加载其他方法
            success: function (result) {
                for(var i=0;i<result.length;i++){
                    html1+=" <div  class=\"col-md-3\">\n" +
                        "        <img src=\"/images/6.jpg\" height=\"225\" width=\"225\">\n" +
                        "        <div class=\"row\">\n" +
                        "            <div class=\"col-sm-12\">\n" +
                        "                <h4>"+result[i].s_name+"<label class=\"s_name\"></label></h4>\n" +
                        "            </div>\n" +
                        "        </div>\n" +
                        "        <div class=\"row\">\n" +
                        "            <div class=\"col-sm-3\" style=\"color: crimson\" >\n" +
                        "                <h5>"+result[i].s_price+"￥<label class=\"s_price\"></label></h5>\n" +
                        "            </div>\n" +
                        "            <div class=\"col-sm-3\" >\n" +
                        "                <h7>课时："+result[i].s_time+"<label class=\"s_time\"></label></h7>\n" +
                        "            </div>\n" +
                        "        </div>\n" +
                        "        <div class=\"row \">\n" +
                        "            <div>\n" +
                        "                <button class=\"btn1 btn-info\"style=\"margin-left:20px\">\n" +
                        "                    点击试看\n" +
                        "                </button>\n" +
                        "                <button id='"+result[i].s_id+"' class=\"goinfo btn-success col-sm-offset-1 \">\n" +
                        "                    加入购物车\n" +
                        "                </button>\n" +
                        "            </div>\n" +
                        "        </div>\n" +
                        "    <div class='row' style='height: 50px' '></div></div>";

                }
                $("#xt").html(html1);
            }

        });


        $(document).on("click",".goinfo",function () {
            var id=$(this).attr("id");
            sessionStorage.setItem("s_id",id);
            alert(id);
        })

        function getInfo(s_id) {
            $.ajax({
                url: "sixCourse/getInfoById",
                type: "post",
                dataType: "json",
                // async:false,//同步方法，确保获取到id在加载其他方法
                data: {
                    s_id: s_id
                },
                success: function (result) {
                    console.log(JSON.stringify(result));
                    var files = result.object;
                    var html = "";
                    // for (var i = 0; i < files.length; i++) {
                    //     html += "<img src='" + files[i] + "' height='300' width='400'></img><br/>"
                    // }
                    // $(".s_name").text(result.objectMap.sixCourseModel.s_name);
                    // $(".s_price").text(result.objectMap.sixCourseModel.s_price);
                    // $(".s_time").text(result.objectMap.sixCourseModel.s_time);
                    // $(".s_surface").attr("src",result.objectMap.sixCourseModel.s_surface);
                }
            });
        }
    })
</script>
</body>
</html>